package com.woniuxy.educationplatform.mapper;

import com.woniuxy.educationplatform.bean.AdminBean;
import com.woniuxy.educationplatform.bean.OptBean;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

@Mapper
public interface OptMapper {

    @Results({
            @Result(column = "fk_admin_id",property = "adminBean",javaType = AdminBean.class,one =
            @One(select = "com.woniuxy.educationplatform.mapper.AdminMapper.findAdminById",fetchType = FetchType.LAZY))
    })
    @Select("select fk_admin_id,opt_time as optTime,order_status as orderStatus," +
            "order_pay as orderPay,order_send as orderSend,type from opt_info where fk_order_id = #{id}")
    List<OptBean> findByOrderId(Long id);


    @Insert("insert into opt_info (fk_admin_id,opt_time,order_status,order_pay,order_send,type,fk_order_id)" +
            "values (1,now(),#{o.orderStatus},#{o.orderPay},#{o.orderSend},#{o.type},#{o.orderBean.id})")
    void add(@Param("o") OptBean optBean);
}
